/**
 * Project Name:Micro-Services-Common
 * File Name   :URL.java
 * Package Name:com.micro.services.common
 * Date:2015-9-8上午9:46:28
 * Copyright (c) 2015, http://my.oschina.net/httpssl All Rights Reserved.
 *
*/

package com.micro.services.common;

import java.io.Serializable;

/**
 * ClassName:URL <br/>
 * Function :TODO ADD FUNCTION. <br/>
 * Reason	:学习自Dubbo. <br/>
 * Date     :2015-9-8 上午9:46:28 <br/>
 * @author  :http://my.oschina.net/httpssl
 * @email   :491835898@QQ.COM
 * @since   :JDK 1.7
 * @see 	 
 */
public class URL implements Serializable
{
	private static final long	serialVersionUID	= 1L;
	private final char END_TAG='/';
	private String protocol;
	private String host;
	private int port = -1;
	
	public URL(){
	}
	
	public URL(String protocol, String host){
		this(protocol,host,-1);
	}
	public URL(String protocol, String host, int port){
		this.protocol = protocol;
		this.host = host;
		this.port = port;
	}
	
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append(protocol).append(":").append("//").append(host).append(port==-1?"":":"+port).append(END_TAG);
		return builder.toString();
	}
	public static void main(String[] args) {
		System.out.println(new URL("http","localhost"));
		System.out.println(new URL("tcp","127.0.0.1",1000));
	}
	
	
	
	
	
	
	
}